<?php
class Application_Model_Manager {
	protected static $instance = null;
	static public function getInstance() {
		if (is_null ( self::$instance ))
			self::$instance = new self ();
		return self::$instance;
	}
	
	protected $_mappers;
	protected function __construct() {
		$this->_mappers = array ();
	}
	
	public function __get($name) {
		if (array_key_exists ( $name, $this->_mappers ))
			return $this->_mappers [$name];
		
		$class_name = 'Api_DbTable_' . ucfirst ( strtolower ( $name ) );
		
		try {
			$this->_mappers [$name] = new $class_name ();
			$this->_mappers [$name]->setManager ( $this );
			return $this->_mappers [$name];
		} catch ( Exception $e ) {
			return null;
		}
	
	}
}